﻿using System.Globalization;
using System.Threading;

namespace Loki.UI
{
    public static class UIContext
    {
        private static SynchronizationContext _SyncContext;

        public static void ProtectUIDispatcher(SendOrPostCallback P_CallBack)
        {
            if (_SyncContext != null)
            {
                _SyncContext.Post(P_CallBack, null);
            }
            else
            {
                P_CallBack(null);
            }
        }

        public static void Configure()
        {
            _Thread = Thread.CurrentThread;
            _SyncContext = SynchronizationContext.Current;
        }

        private static Thread _Thread;

        public static CultureInfo Culture
        {
            get { return _Thread.CurrentUICulture; }
        }
    }
}
